package handler

import (
	"6-17yk/client/client"
	"6-17yk/client/request"
	"6-17yk/client/response"
	"6-17yk/common/proto/user"
	"github.com/gin-gonic/gin"
)

func OrderCreate(c *gin.Context) {
	ui := c.GetUint("userId")
	var data request.OrderCreate
	err := c.ShouldBind(&data)
	if err != nil {
		response.ResponseError(c, err.Error())
		return
	}
	create, err := client.OrderCreate(c, &user.OrderCreateReq{
		UserId:        int64(ui),
		InstitutionId: int64(data.InstitutionId),
		TeamId:        int64(data.TeamId),
		DoctorId:      int64(data.DoctorId),
		ServicePack:   data.ServicePack,
		SingCycle:     data.SingCycle,
		Price:         float32(data.Price),
		Notes:         data.Notes,
		PayWay:        int64(data.PayWay),
		OrderStatus:   int64(data.OrderStatus),
	})
	if err != nil {
		response.ResponseError(c, err.Error())
		return
	}
	response.ResponseSuccess(c, create)
}
